/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","hammerjs","promise","ojs/ojjquery-hammer","ojs/ojcomponentcore"],function(a,g,b){a.j={};o_("OffcanvasUtils",a.j,a);a.j.RP="oj-offcanvasEdge";a.j.dq="oj-offcanvas";a.j.SP="oj-mediaQueryListener";a.j.Q1="oj-offcanvasHammer";a.j.R1="oj-offcanvasStyle";a.j.FB="selector";a.j.vx="content";a.j.uu="start";a.j.tu="end";a.j.qB="top";a.j.IG="bottom";a.j.qu="displayMode";a.j.su="push";a.j.OO="overlay";a.j.k0="pin";a.j.Dla="modality";a.j.mMa="none";a.j.Ela="modal";a.j.HG="_dismissHandler";
a.j.mP="_openPromise";a.j.oB="_closePromise";a.j.yu="_glassPane";a.j.a1="_surrogate";a.j.tP="data-oj-offcanvas-surrogate-id";a.j.Ola="oj-offcanvas-outer-wrapper";a.j.BB="oj-offcanvas-open";a.j.lh="oj-offcanvas-transition";a.j.M0="oj-offcanvas-pin";a.j.L0="oj-offcanvas-pin-transition";a.j.kla="oj-offcanvas-glasspane";a.j.tB="oj-offcanvas-glasspane-dim";a.j.hma="ojbeforeopen veto";a.j.gma="ojbeforeclose veto";a.j.xEa={start:"oj-offcanvas-shift-start",end:"oj-offcanvas-shift-end",top:"oj-offcanvas-shift-down",
bottom:"oj-offcanvas-shift-up"};a.j.wta={start:"oj-offcanvas-start",end:"oj-offcanvas-end",top:"oj-offcanvas-top",bottom:"oj-offcanvas-bottom"};a.j.Mua=function(b){b=b[a.j.qu];b!==a.j.OO&&b!==a.j.su&&b!==a.j.k0&&(b=(a.Wc.De("oj-offcanvas-option-defaults")||{}).displayMode);return b};a.j.Jg=function(b){return g(b[a.j.FB])};a.j.kz=function(b){return b[a.j.Dla]===a.j.Ela};a.j.Ws=function(b){return b.hasClass(a.j.BB)};a.j.Ks=function(b){return b.closest("."+a.j.Ola)};a.j.lJ=function(b){var d=a.j.Jg(b);
return a.j.Raa(b)||b[a.j.qu]===a.j.OO?d:d.parent()};a.j.Qva=function(b){var d=a.j.xEa[b];if(!d)throw"Invalid edge: "+b;return d};a.j.gg=function(){return"rtl"===a.D.In()};a.j.Xk=function(a,b){a.css({"-webkit-transform":b,transform:b})};a.j.XJ=function(b,d,e){b=b===a.j.tu;if(a.j.gg()||e)b=!b;return"translate3d("+(b?"-":"")+d+", 0, 0)"};a.j.ME=function(b,d,e){a.j.Xk(b,a.j.XJ(d,e,!1))};a.j.e9=function(b,d){return"translate3d(0, "+(b===a.j.IG?"-":"")+d+", 0)"};a.j.lEa=function(b,d,e){a.j.Xk(b,a.j.e9(d,
e))};a.j.f9=function(a,b){return"translate3d(0, "+(b?"-":"")+a+", 0)"};a.j.vDa=function(b,d,e){b.addClass(a.j.lh);a.j.Xk(b,"translate3d(0, 0, 0)");d.addClass(a.j.lh);a.j.Xk(d,e)};a.j.Fca=function(b){var d=b.edge;b=a.j.Jg(b);d&&d.length||(d=b.hasClass("oj-offcanvas-start")?a.j.uu:b.hasClass("oj-offcanvas-end")?a.j.tu:b.hasClass("oj-offcanvas-top")?a.j.qB:b.hasClass("oj-offcanvas-bottom")?a.j.IG:a.j.uu);g.data(b[0],a.j.RP,d);return d};a.j.pT=function(b){return g.data(b[0],a.j.RP)};a.j.UE=function(b,
d,e){var f=b[a.j.qu],g=a.j.Jg(b),k=a.j.BB,f=f===a.j.OO?a.j.lh+" oj-offcanvas-overlay":a.j.lh;e?(g.addClass(k),d.addClass(f)):(b.makeFocusable&&a.D.TN({element:g,remove:!0}),b=b.tabindex,void 0===b?g.removeAttr("tabindex"):g.attr("tabindex",b),g.removeClass(k),d.removeClass(f))};a.j.Zj=function(b){var d=a.j.Jg(b),e=d.find("[autofocus]");0==e.length&&(e=d.find(":tabbable"));0==e.length?(e=d.attr("tabindex"),void 0!==e&&(b.tabindex=e),d.attr("tabindex","-1"),e=d,a.D.TN({element:d,applyHighlight:!0}),
b.makeFocusable=!0):e=e[0];a.me.qF(e)};a.j.kza=function(a){return"none"!=a.autoDismiss};a.j.Wo=function(a,b){function e(){b(a);a.off("transitionend.oc webkitTransitionEnd.oc otransitionend.oc oTransitionEnd.oc",e)}a.on("transitionend.oc webkitTransitionEnd.oc otransitionend.oc oTransitionEnd.oc",e)};a.j.x5=function(b){a.j.close(b)["catch"](function(b){a.t.warn("Offcancas close failed: "+b)})};a.j.zE=function(b){a.j.CX(b);if(a.j.kza(b)){var d=a.j.Jg(b),e=b[a.j.HG]=function(e){var f=e.target;a.D.Qha(e)||
"focus"===e.type&&!g(f).is(":focusable")||(null==g.data(d[0],a.j.dq)?a.j.CX(b):a.D.QJa(d[0],f)||a.j.x5(b))},f=document.documentElement;a.D.jf()&&f.addEventListener("touchstart",e,!0);f.addEventListener("mousedown",e,!0);f.addEventListener("focus",e,!0)}a.j.Dz(b)};a.j.CX=function(b){var d=b[a.j.HG];if(d){var e=document.documentElement;a.D.jf()&&e.removeEventListener("touchstart",d,!0);e.removeEventListener("mousedown",d,!0);e.removeEventListener("focus",d,!0);delete b[a.j.HG];b[a.j.HG]=null}a.j.PL(b)};
a.j.Dz=function(c){if(a.D.jf()){var d=c[a.j.FB],e=g(d),f=a.j.pT(e),h,k;f===a.j.uu&&!a.j.gg()||f===a.j.tu&&a.j.gg()?(k={recognizers:[[b.Swipe,{direction:b.DIRECTION_LEFT}]]},h="swipeleft"):f===a.j.uu&&a.j.gg()||f===a.j.tu&&!a.j.gg()?(k={recognizers:[[b.Swipe,{direction:b.DIRECTION_RIGHT}]]},h="swiperight"):f===a.j.qB?(k={recognizers:[[b.Swipe,{direction:b.DIRECTION_UP}]]},h="swipeup"):f===a.j.IG&&(k={recognizers:[[b.Swipe,{direction:b.DIRECTION_DOWN}]]},h="swipedown");f=e.rj(k).on(h,function(b){b.target===
e[0]&&(b.preventDefault(),a.j.x5(c))});g.data(g(d)[0],a.j.Q1,{event:h,hammer:f})}};a.j.PL=function(b){b=a.j.Jg(b);0<b.length&&(b=g.data(b[0],a.j.Q1))&&b.hammer.off(b.event)};a.j.uza=function(b){return a.j.Ks(b).hasClass("oj-offcanvas-page")};a.j.yK=function(b){return b[a.j.qu]===a.j.k0};a.j.Raa=function(b){return b[a.j.vx]||a.j.uza(a.j.Jg(b))||a.j.yK(b)};a.j.iDa=function(b){var d=b.attr("style");void 0!==d&&g.data(b[0],a.j.R1,d)};a.j.dDa=function(b){var d=g.data(b[0],a.j.R1);d?b.attr("style",d):b.removeAttr("style")};
a.j.Rq=function(b,d){var e=a.j.pT(b),e=a.j.Qva(e),f=a.j.Ks(b);a.p.ve(f,g);var h=f.hasClass(e);d||f.toggleClass(e,!h);return h};a.j.NI=function(a,b){function e(){null==("fixed"===g(a).css("position")?a.parentNode.offsetParent:a.offsetParent)?b():f=window.requestAnimationFrame(e)}var f=0,f=window.requestAnimationFrame(e);return function(){0!==f&&window.cancelAnimationFrame(f)}};a.j.qs=function(b){var d=a.j.Jg(b),e=a.j.yK(b);if(g.data(d[0],a.j.dq)===b){a.j.pT(d);var f=a.j.lJ(b);e?d.removeClass(a.j.BB+
" "+a.j.L0):a.j.UE(b,f,!1);a.j.zCa(b);a.j.CX(b);e&&(a.j.Ks(d).removeClass(a.j.M0),a.j.dDa(d));d.trigger("ojclose",b);g.removeData(d[0],a.j.dq)}};a.j.rda=function(b,d,e){var f=g(b);(d=!!d)&&a.j.Ws(f)&&a.j.qq(b,!1);f.toggleClass(a.j.wta[e],!d)};a.j.ELa=function(b){var d=b.query;if(null!==d){var e=b[a.j.FB],d=window.matchMedia(d),f=a.j.Fca(b);b=function(b){a.j.rda(e,b.matches,f)};d.addListener(b);a.j.rda(e,d.matches,f);g.data(g(e)[0],a.j.SP,{mqList:d,mqListener:b})}};o_("OffcanvasUtils.setupResponsive",
a.j.ELa,a);a.j.SLa=function(b){b=a.j.Jg(b);var d=g.data(b[0],a.j.SP);d&&(d.mqList.removeListener(d.mqListener),g.removeData(b[0],a.j.SP))};o_("OffcanvasUtils.tearDownResponsive",a.j.SLa,a);a.j.ZAa=function(b,d,e){function f(e){e.removeClass(a.j.lh);l?l=!1:(a.j.Zj(b),h.trigger("ojopen",b),a.j.zE(b),d(!0))}var h=a.j.Jg(b),k=g(b[a.j.vx]);a.p.ve(k,g);var l=!0,m=b.size,r;h.addClass(a.j.BB);window.setTimeout(function(){e===a.j.uu||e===a.j.tu?(void 0===m&&(m=h.outerWidth(!0)+"px"),a.j.Xk(h,a.j.XJ(e,m,!0)),
r=a.j.XJ(e,m,!1)):(void 0===m&&(m=h.outerHeight(!0)+"px"),a.j.Xk(h,a.j.f9(m,e===a.j.qB)),r=a.j.f9(m,e!==a.j.qB));window.setTimeout(function(){a.j.vDa(h,k,r);a.j.Rq(h,!1)},0)},0);a.j.jI(b,h);a.j.Wo(k,f);a.j.Wo(h,f)};a.j.UAa=function(b,d,e){var f=a.j.Jg(b);a.j.UE(b,f,!0);var g=b.size;g&&(e===a.j.uu||e===a.j.tu?a.j.Xk(f,a.j.XJ(e,g,!0)):a.j.Xk(f,a.j.e9(e,g)));window.setTimeout(function(){a.j.Rq(f,!1)},20);a.j.jI(b,f);a.j.Wo(f,function(){f.removeClass(a.j.lh);a.j.Zj(b);f.trigger("ojopen",b);a.j.zE(b);
d(!0)})};a.j.VAa=function(b,d){var e=a.j.Jg(b),f=g(b[a.j.vx]);a.p.ve(f,g);var h=b.size;e.addClass(a.j.BB);window.setTimeout(function(){void 0===h&&(h=e.outerWidth(!0)+"px");e.addClass(a.j.L0);a.j.Ks(e).addClass(a.j.M0);a.j.iDa(e);a.j.Xk(e,"none");window.setTimeout(function(){e.css("min-width",h);a.j.Rq(e,!1)},10)},0);a.j.jI(b,e);a.j.Wo(e,function(){a.j.Zj(b);e.trigger("ojopen",b);a.j.zE(b);d(!0)})};a.j.ora=function(b,d,e,f){function h(e){l&&e?l=!1:(k.removeClass(a.j.lh),a.j.Xk(k,""),a.j.qs(b),m&&
m(),d(!0))}var k=g(b[a.j.vx]),l=!0,m;f&&(a.j.Wo(e,h),a.j.Wo(k,h),m=a.j.NI(e[0],h));a.j.Xk(e,"");a.j.Xk(k,"");a.j.Rq(e,!1);a.j.kz(b)&&b[a.j.yu].removeClass(a.j.tB);f?(k.addClass(a.j.lh),e.addClass(a.j.lh)):(a.j.qs(b),d(!0))};a.j.mra=function(b,d,e,f){function g(){a.j.qs(b);k&&k();d(!0)}var k;f&&(a.j.Wo(e,g),k=a.j.NI(e[0],g));a.j.Rq(e,!1);a.j.kz(b)&&b[a.j.yu].removeClass(a.j.tB);f?e.addClass(a.j.lh):(a.j.qs(b),d(!0))};a.j.TAa=function(b,d,e,f){var h=a.j.Jg(b),k=a.j.lJ(b);a.p.ve(k,g);a.j.UE(b,k,!0);
var l;e===a.j.uu||e===a.j.tu?(l=void 0===l?h.outerWidth(!0)+"px":l,f===a.j.su&&a.j.ME(k,e,l)):(l=void 0===l?h.outerHeight(!0)+"px":l,f===a.j.su&&a.j.lEa(k,e,l));window.setTimeout(function(){a.j.Rq(h,!1)},10);a.j.jI(b,h);a.j.Wo(k,function(){k.removeClass(a.j.lh);a.j.Zj(b);h.trigger("ojopen",b);a.j.zE(b);d(!0)})};a.j.nra=function(b,d,e,f){function g(){a.j.qs(b);k&&k();d(!0)}var k;f&&(a.j.Wo(e,g),k=a.j.NI(e[0],g));a.j.Rq(e,!1);a.j.kz(b)&&b[a.j.yu].removeClass(a.j.tB);f?e.css("min-width","0"):(a.j.qs(b),
d(!0))};a.j.lra=function(b,d,e,f){function g(){a.j.qs(b);m&&m();d(!0)}var k=b[a.j.qu],l=a.j.lJ(b),m;f&&(a.j.Wo(l,g),m=a.j.NI(e[0],g));k===a.j.su&&a.j.Xk(l,"");a.j.Rq(e,!1);a.j.kz(b)&&b[a.j.yu].removeClass(a.j.tB);f?l.addClass(a.j.lh):(a.j.qs(b),d(!0))};a.j.open=function(b){var d=a.j.Jg(b),e=g.data(d[0],a.j.dq);if(e){if(e[a.j.oB])return e[a.j.oB];if(e[a.j.mP])return e[a.j.mP]}var f=!1,h=new Promise(function(e,l){a.p.ve(d,g);var m=a.j.Fca(b),r=g.Event("ojbeforeopen");d.trigger(r,b);if(!1===r.result)return l(a.j.hma),
f=!0,h;var r=a.j.Mua(b),t=a.j.yK(b);!t||m!==a.j.qB&&m!==a.j.IG||(r=a.j.su);var s=g.extend({},b);s[a.j.qu]=r;g.data(d[0],a.j.dq,s);if(b[a.j.vx]){if(!a.j.Raa(b))throw"Error: Both main content selector and the inner wrapper \x3cdiv class\x3d'oj-offcanvas-inner-wrapper'\x3e are provided. Please remove the inner wrapper.";t?a.j.VAa(s,e):r===a.j.su?a.j.ZAa(s,e,m):a.j.UAa(s,e,m)}else a.j.TAa(s,e,m,r)});f||(e=g.data(d[0],a.j.dq))&&(e[a.j.mP]=h);return h};o_("OffcanvasUtils.open",a.j.open,a);a.j.close=function(b){return a.j.qq(b[a.j.FB],
!0)};o_("OffcanvasUtils.close",a.j.close,a);a.j.qq=function(b,d){var e=g(b);a.p.ve(e,g);var f=g.data(e[0],a.j.dq);if(f&&f[a.j.oB])return f[a.j.oB];var h=!1,k=new Promise(function(l,m){if(a.j.Ws(e)){b!=f[a.j.FB]&&l(!0);a.j.Rq(e,!0)||l(!0);var r=g.Event("ojbeforeclose");e.trigger(r,f);if(!1===r.result)return m(a.j.gma),h=!0,k;var r=a.j.yK(f),t=f[a.j.qu];f[a.j.vx]?t===a.j.su?a.j.ora(f,l,e,d):r?a.j.nra(f,l,e,d):a.j.mra(f,l,e,d):a.j.lra(f,l,e,d)}else l(!0)});h||(f=g.data(e[0],a.j.dq))&&(f[a.j.oB]=k);return k};
a.j.toggle=function(b){var d=a.j.Jg(b);a.p.ve(d,g);return a.j.Ws(d)?a.j.close(b):a.j.open(b)};o_("OffcanvasUtils.toggle",a.j.toggle,a);a.j.vpa=function(b){var d=g("\x3cdiv\x3e");d.addClass(a.j.kla);d.attr("role","presentation");d.attr("aria-hidden","true");d.appendTo(b.parent());d.on("keydown keyup keypress mousedown mouseup mouseover mouseout click focusin focus",function(a){a.stopPropagation();a.preventDefault()});return d};a.j.nS=function(b){var d=g("\x3cscript\x3e"),e=b.attr("id");e?(e=[e,"surrogate"].join("_"),
d.attr("id",e)):e=d.uniqueId();d.insertBefore(b);b.attr(a.j.tP,e);return d};a.j.UEa=function(b,d){b[a.j.a1]=a.j.nS(d);d.appendTo(d.parent())};a.j.bDa=function(b){var d=a.j.Jg(b);b=b[a.j.a1];d&&b&&d.attr(a.j.tP)===b.attr("id")&&(d.insertAfter(b),d.removeAttr(a.j.tP),b.remove())};a.j.jI=function(b,d){a.j.kz(b)&&(b[a.j.yu]=a.j.vpa(d),a.j.UEa(b,d),window.setTimeout(function(){b[a.j.yu].addClass(a.j.tB)},0))};a.j.zCa=function(b){a.j.kz(b)&&(b[a.j.yu].remove(),a.j.bDa(b))};a.j.bka=function(c){var d,e,f,
h,k,l,m,r,t,s,q,p;null==g(c).attr("oj-data-pansetup")&&(g(c).attr("oj-data-pansetup","true"),c.displayMode="push",d=a.j.Jg(c),e=c.size,null==e&&(e=d.outerWidth()),f=a.j.Ks(d),h=a.j.lJ(c),k={recognizers:[[b.Pan,{direction:b.DIRECTION_HORIZONTAL}]]},l=!1,g(f).rj(k).on("panstart",function(e){m=null;switch(e.gesture.direction){case b.DIRECTION_LEFT:Math.abs(e.gesture.deltaY)<Math.abs(e.gesture.deltaX)&&(m=a.j.gg()?"end":"start");break;case b.DIRECTION_RIGHT:Math.abs(e.gesture.deltaY)<Math.abs(e.gesture.deltaX)&&
(m=a.j.gg()?"start":"end")}null!=m&&(r={direction:m,distance:Math.abs(e.gesture.deltaX)},t=g.Event("ojpanstart"),d.trigger(t,r),t.isDefaultPrevented()||(c._closePromise=null,h.off(".oc"),a.j.UE(c,h,!0),l=!0,e.gesture.srcEvent.stopPropagation(),e.stopPropagation()))}).on("panmove",function(b){l&&(s=b.gesture.deltaX,"start"==m&&0<s||"end"==m&&0>s?a.j.ME(h,"start","0px"):(d.css("width",Math.abs(s)),h.removeClass(a.j.lh),a.j.ME(h,"start",s+"px"),r={direction:m,distance:Math.abs(s)},t=g.Event("ojpanmove"),
d.trigger(t,r),b.gesture.srcEvent.stopPropagation(),b.stopPropagation()))}).on("panend",function(b){l&&(l=!1,s=Math.abs(b.gesture.deltaX),r={distance:s},t=g.Event("ojpanend"),d.trigger(t,r),b.stopPropagation(),t.isDefaultPrevented()?(p=function(){a.j.UE(c,h,!1);h.removeClass(a.j.lh);h.off("transitionend webkitTransitionEnd otransitionend oTransitionEnd",p)},h.on("transitionend webkitTransitionEnd otransitionend oTransitionEnd",p),h.addClass(a.j.lh),a.j.ME(h,"start","0px")):(q=c.edge,null==q&&(q=d.hasClass("oj-offcanvas-start")?
"start":"end"),a.j.Zpa(h,d,q,e),g.data(d[0],a.j.dq,c),g.data(d[0],a.j.RP,q),a.j.zE(c)))}))};o_("OffcanvasUtils.setupPanToReveal",a.j.bka,a);a.j.Zpa=function(b,d,e,f){var g,k,l,m,r,t,s,q,p,n;b.removeClass(a.j.lh);g=Math.round(1E3/60);k=b.css("transform").split("(")[1].split(")")[0].split(",");l=parseInt(k[4],10);m="end"==e?0-f:f;t=Math.max(1,Math.abs(m-l)/(400/g));s=(new Date).getTime();q=function(){p=(new Date).getTime();n=Math.max(t,t*Math.max((p-s)/g));s=p;l<m?l=Math.min(m,l+n):l>m&&(l=Math.max(m,
l-n));a.j.ME(b,e,Math.abs(l)+"px");d.css("width",Math.abs(l)+"px");l==m?(window.cancelAnimationFrame(r),b.addClass(a.j.lh)):r=window.requestAnimationFrame(q)};r=window.requestAnimationFrame(q)};a.j.qka=function(b){b=a.j.Jg(b);g(a.j.Ks(b)).off("panstart panmove panend")};o_("OffcanvasUtils.tearDownPanToReveal",a.j.qka,a)});